package com.dmall.scf.enums;


import com.google.common.collect.Maps;

import java.util.Arrays;
import java.util.Map;

/**
 * 供应商状态枚举
 */
public enum DayRangeEnum {

    SEVEN(1,7, "近7日"),
    TEN(2,10, "近10日"),
    FIFTEN(3,15, "近15日"),
    TWENTY(4,20, "近20日"),
    THIRTY(5,30, "近30日"),
    THREE_MONTH(6,90, "近3个月(90日)"),
    SIX_MONTH(7,180, "近6个月(180日)"),
    ONE_YEAR(8,365, "近1年(365日)");

    private int status;
    private int value;
    private String title;

    DayRangeEnum(int status, int value, String title) {
        this.status = status;
        this.value = value;
        this.title = title;
    }

    public int getStatus() {
        return status;
    }

    public int getValue() {
        return value;
    }

    public String getTitle() {
        return title;
    }

    public static DayRangeEnum codeOf(int status) {
        for (DayRangeEnum elem : values()) {
            if (elem.getStatus() == status) {
                return elem;
            }
        }
        throw new UnsupportedOperationException("不支持的RefundStatusEnum code值:" + status);
    }

    /**
     *  获取状态与值对应关系
     * @return
     */
    public static Map<Integer, Integer> getStaValMap(){
        Map<Integer, Integer> returnMap = Maps.newHashMap();
        Arrays.stream(DayRangeEnum.values()).forEach(x->returnMap.put(x.status, x.value));
        return returnMap;
    }
}
